package cn.yh.register.hosp.service.impl;

import cn.yh.register.common.exception.RegisterException;
import cn.yh.register.common.result.ResultCodeEnum;
import cn.yh.register.hosp.mapper.HospitalSetMapper;
import cn.yh.register.hosp.service.HospitalSetService;
import cn.yh.register.model.hosp.HospitalSet;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HospitalSetServiceImpl extends ServiceImpl<HospitalSetMapper, HospitalSet> implements HospitalSetService {
    /**
     * 获取签名key
     * @param hoscode 医院编号
     * @return 签名key
     */
    @Override
    public String getStringKey(String hoscode) {

        HospitalSet hospitalSet = baseMapper.selectOne(new LambdaQueryWrapper<HospitalSet>()
                .eq(HospitalSet::getHoscode, hoscode));
        if (hospitalSet == null) {
            throw new RegisterException(ResultCodeEnum.HOSPITAL_OPEN);
        }
        return hospitalSet.getSignKey();
    }

}

